﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HomeWork5
{
    class OrderItem
    {
        public Product Product { get; set; }
        public int ProductNumber { get; set; }
        public OrderItem(Product Product, int ProductNumber)
        {
            this.Product = Product;
            this.ProductNumber = ProductNumber;
        }

        public override bool Equals(object obj)
        {
            return obj is OrderItem item &&
                   EqualityComparer<Product>.Default.Equals(Product, item.Product) &&
                   ProductNumber == item.ProductNumber;
        }

        public override int GetHashCode()
        {
            var hashCode = 1525285707;
            hashCode = hashCode * -1521134295 + EqualityComparer<Product>.Default.GetHashCode(Product);
            hashCode = hashCode * -1521134295 + ProductNumber.GetHashCode();
            return hashCode;
        }
        public override string ToString()
        {
            return this.Product.ToString() + ": " + this.ProductNumber;
        }
    }
}
